package dy.spec.edu.week12_class01;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

public class SubscribleAdapter extends RecyclerView.Adapter<SubscribleAdapter.ViewHolder> {
    private List<Subscrible> SubscribleList;
    static class ViewHolder extends RecyclerView.ViewHolder{
        ImageView subscribleImage;
        TextView subscribleName;
        public ViewHolder(View view){
            super(view);
            subscribleImage=(ImageView) view.findViewById(R.id.imageId);
            subscribleName=(TextView) view.findViewById(R.id.content);
        }
    }

    public SubscribleAdapter() {
    }

    public SubscribleAdapter(List<Subscrible> SubscribleList) {
        this.SubscribleList = SubscribleList;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view=LayoutInflater.from(parent.getContext()).inflate(R.layout.subscrible_item,parent,false);
        ViewHolder holder=new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder( ViewHolder holder,int position) {
        Subscrible s = SubscribleList.get(position);
        holder.subscribleImage.setImageResource(s.getImageId());
        holder.subscribleName.setText(s.getContent());
    }

    @Override
    public int getItemCount() {
        return SubscribleList.size();
    }
}

